package com.water.camera.mark;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.water.camera.bean.EditItem;
import com.water.camera.databinding.LayoutWatermark56Binding;

import java.text.SimpleDateFormat;
import java.util.ArrayList;

public class Mark56 extends BaseMark {

    LayoutWatermark56Binding binding;

    public Mark56(@NonNull Context context) {
        super(context);
    }

    public Mark56(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Mark56(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void init(int type) {
        if (type == 0) {
            binding = LayoutWatermark56Binding.inflate(LayoutInflater.from(getContext()));
            addView(binding.getRoot());
            hideView(binding.binding8, binding.binding10, binding.binding12, binding.binding14, binding.binding16, binding.binding18, binding.binding20, binding.binding22, binding.binding24);
        } else {
            binding = LayoutWatermark56Binding.inflate(LayoutInflater.from(getContext()), this, true);
        }
        update();
    }

    @Override
    public void update() {
        setText(binding.binding1, "text56", binding.binding1);
        setText(binding.binding3, "title56", binding.binding2);
        setText(binding.binding5, "content56", binding.binding4);
        setText(binding.binding7, "no56", binding.binding6);
        setText(binding.binding9, "count56", binding.binding8);
        setText(binding.binding11, "time56", binding.binding10);
        setTime(binding.binding11, new SimpleDateFormat("yyyy.MM.dd HH:mm"));

        setText(binding.binding13, "weather56", binding.binding12);
        setText(binding.binding15, "didian56", binding.binding14);
        setText(binding.binding17, "height56", binding.binding16);
        setText(binding.binding19, "angle56", binding.binding18);
        setText(binding.binding21, "speed56", binding.binding20);
        setText(binding.binding23, "jingwei56", binding.binding22);
        setText(binding.binding25, "beizhu56", binding.binding24);

        super.update();
    }

    @Override
    public ArrayList<EditItem> getEditItems() {
        ArrayList<EditItem> list = new ArrayList<>();
        list.add(new EditItem("text56", "自定义文字"));
        list.add(new EditItem("title56", "标题"));
        list.add(new EditItem("content56", "内容"));

        list.add(new EditItem("no56", "编号"));
        list.add(new EditItem("count56", "计数"));
        list.add(new EditItem("time56", "时间", true));
        list.add(new EditItem("weather56", "天气"));
        list.add(new EditItem("didian56", "地点"));
        list.add(new EditItem("height56", "海拔"));
        list.add(new EditItem("angle56", "方位角"));

        list.add(new EditItem("speed56", "速度"));
        list.add(new EditItem("jingwei56", "经纬度"));
        list.add(new EditItem("beizhu56", "备注"));

        return list;
    }

    @Override
    public void onValueChange(EditItem item) {
        if (item.isTime) {
            setTime(binding.binding11, new SimpleDateFormat("yyyy.MM.dd HH:mm"));
        } else {
            super.onValueChange(item);
        }
    }
}
